

class PeopleDependancies:
    def __init__(self, SQLConn, dBName = "PEOPLE_Dependancies"):
        self.SQLConn = SQLConn
        self.PeopleDepTable = dBName
        
    def AddDependancy(self, Person_ID, Dependant_ID):
        self.SQLConn.SendCommand("""
         INSERT INTO %s (Peo_id, Dep_id)
         VALUES ('%d', '%d')
        """ %(self.PeopleDepTable, Person_ID, Dependant_ID))
    
    def RemoveDependacy(self, Person_ID, Dependant_ID):
        self.SQLConn.SendCommand("""    
         DELETE FROM %s where Peo_id=%d AND Dep_id=%d
         """ %(self.PeopleDepTable, Person_ID, Dependant_ID))
        
    def RemovePersonsDeps(self, PID):
        self.SQLConn.SendCommand("""    
         DELETE FROM %s where Peo_id=%d
         """ % (self.PeopleDepTable, PID))
        
        
        
    def GetAllPersonsDeps(self, Person_ID):
        Payments = []
        self.SQLConn.SendCommand("""SELECT Dep_id FROM %s WHERE Peo_id = %d"""%(self.PeopleDepTable,Person_ID))
        rows = self.SQLConn.FetchAll ()
        Deps = []
        for Dep in rows:
            Deps.append(Dep[0])
        return Deps
    
        
       
    
def GenerateTables(SQL):
    print """Generating "PEOPLE_Dependancies" Table"""
    
    SQL.SendCommand ("DROP TABLE IF EXISTS PEOPLE_Dependancies")
    SQL.SendCommand("""CREATE TABLE PEOPLE_Dependancies(
                    Peo_id int,
                    Dep_id int)
                    """)